fix(next-mdx): forward plugin load errors to webpack callback#94119
fix(next-mdx): forward plugin load errors to webpack callback#94119Jinoko01 wants to merge 4 commits into
Conversation
timneutkens
left a comment
There was a problem hiding this comment.
Can you add a test for the changes. You can use pnpm new-test (or ask an AI agent)
Thanks for the review! I've added a test in test/e2e/app-dir/mdx/mdx.test.ts that verifies the error is properly forwarded to webpack's callback when a plugin path fails to resolve. The test patches next.config.ts with a non-existent remark plugin, attempts a production build, and asserts two things:
|
| skipStart: true, | ||
| }) | ||
|
|
||
| if (!isNextStart) { |
There was a problem hiding this comment.
This will still create the isolated dir before skipping for dev. It's preferable to skip based on importing isNextStart from e2e-utils in this case.
import { nextTestSetup, isNextStart } from 'e2e-utils'
Then use it to skip the describe:
;(isNextStart ? describe : describe.skip)('mdx without-mdx-rs - invalid plugin error handling', () => {
There was a problem hiding this comment.
Good catch! Updated to import isNextStart directly from e2e-utils and wrap the describe with (isNextStart ? describe : describe.skip)(...). This way nextTestSetup is never called in dev mode, so the isolated directory won't be created unnecessarily.
Replace the early-return guard with (isNextStart ? describe : describe.skip) so that nextTestSetup — and the isolated directory creation — is never called outside of next start runs. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
What?
Add
.catch()handler to the Promise inmdx-js-loader.jsso thatplugin resolution failures are properly forwarded to webpack's error callback.
Why?
When a plugin string path fails to resolve (e.g. typo in plugin name,
missing package),
getOptions()returns a rejected Promise. Without.catch(), webpack's callback is never called, causing the build tohang indefinitely or throw an unhandled promise rejection instead of
a clear error message.
How?
Chain
.catch((error) => callback(error))after the existing.then()in
nextMdxLoader.Fixes #94118